<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
    <crudOperation :permission="permission">
      <el-button
              slot="right"
              class="filter-item"
              size="mini"
              type="danger"
              icon="el-icon-remove-outline"
              :loading="enable"
              @click="crud.enableOrDisable('DISABLE')"
              :disabled="crud.selections.length < 1"
              v-permission="permission.pass"
      >
        审核
      </el-button>
      <el-button
              slot="right"
              class="filter-item"
              size="mini"
              type="success"
              icon="el-icon-circle-check"
              :loading="able"
              :disabled="crud.selections.length < 1"
              @click="crud.enableOrDisable('ENABLE')"
              v-permission="permission.reject"
      >
        反审
      </el-button>
    </crudOperation>
      <div v-if="!crud.props.searchToggle">
        <el-form size="small" label-width="70px">
          <el-row :gutter="10" style="text-align: center">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户名称">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="销售部门">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="销售人员">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户分类">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户区域">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <rrOperation :crud="crud"/>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="编码">
            <el-input v-model="form.code" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="名称">
            <el-input v-model="form.name" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="成本调整单类型(1:采购 2:其他)">
            <el-input v-model="form.type" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="单据类型(1:按税率调整 2:自定义调整)">
            <el-input v-model="form.orderType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="业务日期">
            <el-input v-model="form.busDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="来源类型(1:手动新增 2:导入 3:采购进货单 4:采购结算单 5:采购退货单 9:红冲)">
            <el-input v-model="form.sourceType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="来源单据id">
            <el-input v-model="form.sourceId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="来源单据号">
            <el-input v-model="form.sourceCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="供应商id">
            <el-input v-model="form.customerId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="供应商编码">
            <el-input v-model="form.customerCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="供应商名称">
            <el-input v-model="form.customerName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否往来(0:客户 1:供应商 2:客户+供应商)">
            <el-input v-model="form.isContact" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="部门id">
            <el-input v-model="form.deptId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="部门编码">
            <el-input v-model="form.deptCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="部门名称">
            <el-input v-model="form.deptName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="人员id">
            <el-input v-model="form.userId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="人员编码">
            <el-input v-model="form.userCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="人员名称">
            <el-input v-model="form.userName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="仓库id">
            <el-input v-model="form.warehouseId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="仓库编码">
            <el-input v-model="form.warehouseCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="仓库名称">
            <el-input v-model="form.warehouseName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="条数">
            <el-input v-model="form.count" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="含税金额">
            <el-input v-model="form.taxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="未税金额">
            <el-input v-model="form.noTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="税额">
            <el-input v-model="form.tax" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否红冲(0:否 1:是)">
            <el-input v-model="form.isRed" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否打印(0:否 1:是)">
            <el-input v-model="form.isPrint" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="打印次数">
            <el-input v-model="form.printCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="排序">
            <el-input v-model="form.seq" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="单据状态(SAVE:保存 PASS:审核 CLOSE:关闭)">
            <el-input v-model="form.orderStatus" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remark" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="单据说明">
            <el-input v-model="form.orderRemark" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="添加人id">
            <el-input v-model="form.createUserId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="添加人编码">
            <el-input v-model="form.createUserCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="添加人名称">
            <el-input v-model="form.createUserName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="添加时间">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改人id">
            <el-input v-model="form.updateUserId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改人编码">
            <el-input v-model="form.updateUserCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改人名称">
            <el-input v-model="form.updateUserName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改时间">
            <el-input v-model="form.updateTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="审核人id">
            <el-input v-model="form.auditUserId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="审核人编码">
            <el-input v-model="form.auditUserCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="审核人名称">
            <el-input v-model="form.auditUserName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="审核时间">
            <el-input v-model="form.auditTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="关闭人id">
            <el-input v-model="form.closeUserId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="关闭人编码">
            <el-input v-model="form.closeUserCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="关闭人名称">
            <el-input v-model="form.closeUserName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="关闭时间">
            <el-input v-model="form.closeTime" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>

      <vue-context-menu :contextMenuData="contextMenuData"
                        @tableConfig="tableConfig"
                        @deletedata="deletedata"></vue-context-menu>
      <!-- 表格配置 -->
      <el-dialog title="表格配置"
                 :visible.sync="tableConfigShow"
                 width="60%">
        <j-table-column-config :columns.sync="crud.header"  @tabSave="tabSave" @pit="pit" />
      </el-dialog>

      <vue-context-menu :contextMenuData="contextMenuData"
                        @tableConfig="tableConfig"
                        @deletedata="deletedata"></vue-context-menu>
      <!-- 表格配置 -->
      <el-dialog title="表格配置"
                 :visible.sync="tableConfigShow"
                 width="60%">
        <j-table-column-config :columns.sync="crud.header"  @tabSave="tabSave" @pit="pit" />
      </el-dialog>

      <!--表格渲染-->
      <el-table ref="table" stripe border v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;"
                v-if="isShowTable"
                @header-dragend="changeColWidth"
                @contextmenu.native="showMenu"
                @selection-change="crud.selectionChangeHandler">
        <el-table-column :render-header="crud.renderHeader" type="selection" width="60" />
        <el-table-column :render-header="crud.renderHeader" type="index" width="60" label="序号"/>
        <el-table-column
          v-if="item.visible"
          v-for="(item, index) in crud.header"
          :key="`col_${index}`"
          :prop="item.prop"
          :label="columnLabel(item)"
          :width="item.width + 'px'"
          :data-porp='item.prop'
          @contextmenu.native="showMenu"
          @header-dragend="changeColWidth"
        >
          <!-- 自定义渲染模版 -->
          <template slot-scope="scope">
            <!-- 当列key为 sort 时，渲染一个手柄icon -->
            <template v-if="item.prop =='sort'">
              <div class="handle_move">
                <i :class="scope.row['sort']" />
              </div>
            </template>
            <template v-else>
              <span v-if="item.type == 1" style="margin-left: 0px">{{scope.row[`${item.prop}`]}}</span>
              <span v-if="item.type == 2" style="margin-left: 0px">{{ parseTime(scope.row[`${item.prop}`])}}</span>
              <span v-if="item.type == 3" style="margin-left: 0px">{{ getDict(`this.dict.label.${item.dictionary}["${scope.row[item.prop]}"]`) }}</span>
            </template>
          </template>
        </el-table-column>

        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('id')" prop="id" label="id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('code')" prop="code" label="编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('name')" prop="name" label="名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('type')" prop="type" label="成本调整单类型(1:采购 2:其他)" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('orderType')" prop="orderType" label="单据类型(1:按税率调整 2:自定义调整)" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('busDate')" prop="busDate" label="业务日期">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.busDate) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceType')" prop="sourceType" label="来源类型(1:手动新增 2:导入 3:采购进货单 4:采购结算单 5:采购退货单 9:红冲)" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceId')" prop="sourceId" label="来源单据id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceCode')" prop="sourceCode" label="来源单据号" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerId')" prop="customerId" label="供应商id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerCode')" prop="customerCode" label="供应商编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerName')" prop="customerName" label="供应商名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isContact')" prop="isContact" label="是否往来(0:客户 1:供应商 2:客户+供应商)" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('deptId')" prop="deptId" label="部门id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('deptCode')" prop="deptCode" label="部门编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('deptName')" prop="deptName" label="部门名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('userId')" prop="userId" label="人员id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('userCode')" prop="userCode" label="人员编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('userName')" prop="userName" label="人员名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('warehouseId')" prop="warehouseId" label="仓库id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('warehouseCode')" prop="warehouseCode" label="仓库编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('warehouseName')" prop="warehouseName" label="仓库名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('count')" prop="count" label="条数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('taxAmount')" prop="taxAmount" label="含税金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('noTaxAmount')" prop="noTaxAmount" label="未税金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('tax')" prop="tax" label="税额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isRed')" prop="isRed" label="是否红冲(0:否 1:是)" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isPrint')" prop="isPrint" label="是否打印(0:否 1:是)" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('printCount')" prop="printCount" label="打印次数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('seq')" prop="seq" label="排序" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('orderStatus')" prop="orderStatus" label="单据状态(SAVE:保存 PASS:审核 CLOSE:关闭)" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('remark')" prop="remark" label="备注" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('orderRemark')" prop="orderRemark" label="单据说明" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createUserId')" prop="createUserId" label="添加人id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createUserCode')" prop="createUserCode" label="添加人编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createUserName')" prop="createUserName" label="添加人名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createTime')" prop="createTime" label="添加时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.createTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateUserId')" prop="updateUserId" label="修改人id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateUserCode')" prop="updateUserCode" label="修改人编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateUserName')" prop="updateUserName" label="修改人名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateTime')" prop="updateTime" label="修改时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.updateTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditUserId')" prop="auditUserId" label="审核人id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditUserCode')" prop="auditUserCode" label="审核人编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditUserName')" prop="auditUserName" label="审核人名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditTime')" prop="auditTime" label="审核时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.auditTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeUserId')" prop="closeUserId" label="关闭人id" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeUserCode')" prop="closeUserCode" label="关闭人编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeUserName')" prop="closeUserName" label="关闭人名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeTime')" prop="closeTime" label="关闭时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.closeTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-permission="['admin','wareStockCostChange:edit','wareStockCostChange:del']" label="操作" width="150px" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <udOperation-->
<!--              :data="scope.row"-->
<!--              :permission="permission"-->
<!--            />-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudWareStockCostChange from '@/api/erp/wareStockCostChange'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

import { publicListKey } from "@/utils/key";
import {getHeaderProperties} from "@/api/erp/headerProperties";
import {tablemixins} from "@/mixins/tablemixins";
import  jTableColumnConfig  from "@/components/jTableColumnConfig/jTableColumnConfig";

// crud交由presenter持有
const defaultCrud = CRUD({ title: '成本调整单',name:'wareStockCostChange', url: 'api/wareStockCostChange', sort: 'id,desc', crudMethod: { ...crudWareStockCostChange }})
const defaultForm = { id: null, code: null, name: null, type: null, orderType: null, busDate: null, sourceType: null, sourceId: null, sourceCode: null, customerId: null, customerCode: null, customerName: null, isContact: null, deptId: null, deptCode: null, deptName: null, userId: null, userCode: null, userName: null, warehouseId: null, warehouseCode: null, warehouseName: null, count: null, taxAmount: null, noTaxAmount: null, tax: null, isRed: null, isPrint: null, printCount: null, seq: null, orderStatus: null, remark: null, orderRemark: null, createUserId: null, createUserCode: null, createUserName: null, createTime: null, updateUserId: null, updateUserCode: null, updateUserName: null, updateTime: null, auditUserId: null, auditUserCode: null, auditUserName: null, auditTime: null, closeUserId: null, closeUserCode: null, closeUserName: null, closeTime: null }
export default {
  name: 'WareStockCostChange',
  components: { pagination, crudOperation, rrOperation, udOperation ,jTableColumnConfig},
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud(),publicListKey,tablemixins],
  data() {
    return {

      permission: {
        add: ['admin', 'wareStockCostChange:add'],
        edit: ['admin', 'wareStockCostChange:edit'],
        del: ['admin', 'wareStockCostChange:del'],
        import: ['admin', 'wareStockCostChange:import'],
        export: ['admin', 'wareStockCostChange:export'],
        copy: ['admin', 'wareStockCostChange:copy'],
        upload: ['admin', 'wareStockCostChange:upload'],
        download: ['admin', 'wareStockCostChange:download'],
        pass: ['admin', 'wareStockCostChange:pass'],
        reject: ['admin', 'wareStockCostChange:reject'],
        closed: ['admin', 'wareStockCostChange:closed'],
        invalid: ['admin', 'wareStockCostChange:invalid'],
        stop: ['admin', 'wareStockCostChange:stop'],
        recover: ['admin', 'wareStockCostChange:recover'],
      },
      rules: {
      }    }
  },
  watch: {
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },

  }
}
</script>

<style scoped>
  .table-img {
    display: inline-block;
    text-align: center;
    background: #ccc;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
</style>
